<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>areaAdminManager</title>


    <!-- Bootstrap -->
    <link rel="stylesheet" href="../commons/bootstrap-3.3.7-dist/css/bootstrap.min.css">
    <!-- 加载bootstrap-select -->
    <link href="../commons/bootstrap-select-1.13.9-dist/css/bootstrap-select.min.css" rel="stylesheet">
    <!-- 加载bootstrap-treeview -->
    <link href="../commons/bootstrap-treeview-1.2.0-dist/bootstrap-treeview.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../commons/css/currency.css">

    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse">
                <span class="sr-only">切换导航</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">CIMS-校园即时通讯系统</a>
        </div>
        <div class="collapse navbar-collapse" id="example-navbar-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="./areaIndex">首页</a></li>
                <li class=""><a href="areaManager">院校管理</a></li>
                <li class=""><a href="areaAdminManager.jsp">院校管理员管理</a></li>
            </ul>
            <ul class="nav navbar-nav" style="float: right">
                <li class=""><a id="loginUser_nav"></a></li>
                <li class=""><a id="logout_nav">注销</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container">
    <div class="page-header">
        <h3 style="align-content: center">院校管理员管理</h3>
    </div>

    <div class="row" style="margin: 0 0 0;">
        <div class="col-md-2">
            <div class="col-md-1" style="padding: 7px 0 7px;">
                <p>省：</p>
            </div>
            <div class="col-md-11">
                <select class="selectpicker form-control" name="provinceId" title="请选择省份" id="provinceSelect">
                    <option value='0'>请选择</option>
                </select>
            </div>
        </div>
        <div class="col-md-2">
            <div class="col-md-1" style="padding: 7px 0 7px;">
                <p>市：</p>
            </div>
            <div class="col-md-11">
                <select class="selectpicker form-control" name="cityId" title="请选择城市" id="citySelect" disabled>
                    <option value>请选择</option>
                </select>
            </div>
        </div>
        <div class="col-md-3">
            <div class="col-md-2" style="padding: 7px 0 7px;">
                <p>院校：</p>
            </div>
            <div class="col-md-10">
                <select class="selectpicker form-control" name="schoolId" title="请选择院校" id="schoolSelect" disabled>
                    <option value>请选择</option>
                </select>
            </div>
        </div>
        <div class="col-md-5">
            <div class="col-md-12">
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="请输入用户名" id="userName_search_input">
                    <span class="input-group-btn">
                        <button class="btn btn-primary" id="search_btn"><span class="glyphicon glyphicon-search"></span>
                            搜索</button>
                        <button class="btn btn-warning" id="reset_btn"><span class="glyphicon glyphicon-refresh"></span>
                            重置</button>
                    </span>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <table class="table table-striped table-bordered" id="areaAdmins-table">
        <thead>
        <tr>
            <th scope="col"><input type="checkbox" id="check_all"></th>
            <th scope="col" class="col-lg-1">用户名</th>
            <th scope="col" class="col-lg-3">所属区域</th>
            <th scope="col" class="col-lg-1">操作人</th>
            <th scope="col" class="col-lg-3">操作时间</th>
            <th scope="col" class="col-lg-4">操作</th>
        </tr>
        </thead>
        <tbody id="empInfo">
        </tbody>
        <tfoot>
        </tfoot>
    </table>
    <!-- 新增  -->
    <div class="modal fade" id="areaAdmin_add_modal"  role="dialog" aria-labelledby="areaAdmin_add_modal" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title"> 新增院校管理员</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form" id="areaAdmin_add_frm">
                        <div class="form-group">
                            <label for="userName_add_modal" class="col-sm-2 control-label"> 用户名：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="userName" id="userName_add_modal"
                                       placeholder="请输入用户名">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="userPassword_add_modal" class="col-sm-2 control-label"> 密码：</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" name="userPassword" id="userPassword_add_modal"
                                       placeholder="请输入密码">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"> 省：</label>
                            <div class="col-sm-10">
                                <select class="selectpicker form-control" name="provinceId" title="请选择省份"
                                        id="provinceSelect_add_modal">
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"> 市：</label>
                            <div class="col-sm-10">
                                <select class="selectpicker form-control" name="cityId" title="请选择城市"
                                        id="citySelect_add_modal" disabled>
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"> 院校：</label>
                            <div class="col-sm-10">
                                <select class="selectpicker form-control" name="userAreaId" title="请选择院校"
                                        id="schoolSelect_add_modal" disabled>
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"> 关闭</button>
                    <button type="button" class="btn btn-primary" id="areaAdmin_save_btn"> 保存</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <!-- 修改  -->
    <div class="modal fade" id="areaAdmin_modify_modal" tabindex="-1" role="dialog"
         aria-labelledby="areaAdmin_modify_modal" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title"> 修改院校管理员</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form" id="areaAdmin_modify_frm">
                        <div class="form-group">
                            <label for="userName_modify_modal" class="col-sm-2 control-label"> 用户名：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="userName" id="userName_modify_modal"
                                       placeholder="请输入用户名">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"> 省：</label>
                            <div class="col-sm-10">
                                <select class="selectpicker form-control" name="provinceId" title="请选择省份"
                                        id="provinceSelect_modify_modal">
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"> 市：</label>
                            <div class="col-sm-10">
                                <select class="selectpicker form-control" name="cityId" title="请选择城市"
                                        id="citySelect_modify_modal">
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"> 院校：</label>
                            <div class="col-sm-10">
                                <select class="selectpicker form-control" name="userAreaId" title="请选择院校"
                                        id="schoolSelect_modify_modal">
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"> 关闭</button>
                    <button type="button" class="btn btn-primary" id="areaAdmin_modify_btn"> 保存</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <div class="footer ">
        <div class="container">
            <div class="row footer-bottom">
                <ul class="list-inline text-center">
                    <li> Campus Instant Messaging System @2020 杭州职业技术学院 软件技术专业</li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="../commons/js/jquery.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="../commons/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="../commons/bootstrap-treeview-1.2.0-dist/bootstrap-treeview.min.js"></script>
<script src="../commons/bootstrap-select-1.13.9-dist/js/bootstrap-select.min.js"></script>
<script src="../commons/js/login.js"></script>


<script>

    var provinceId, cityId, schoolId, userName, pn;
    $(function () {
        pn = 1;
        getAreaList("#provinceSelect", "全部省份", "", "");
        to_page(pn);
    });

    function to_page(pn) {
        $.ajax({
            url: "../user/areaAdmins",
            type: "GET",
            data: {"provinceId": provinceId, "cityId": cityId, "schoolId": schoolId, "userName": userName, "pn": pn},
            dataType: "json",
            beforeSend: function () {
                $("#areaAdmins-table tbody").empty();
                $("#areaAdmins-table tfoot").empty();
                $("#areaAdmins-table tbody").append("<tr><td colspan='6'>正在加载数据，请稍后...</td></tr>");
            },
            success: function (result) {
                if (result.code == 100) {
                    //查询成功，解析并显示数据
                    //1、显示院校管理员信息
                    build_areaAdmins_table(result);
                    //2、显示分页信息
                    build_page_nav(result);
                } else {

                }
            },
            error: function () {
                $("#areaAdmins-table tbody").empty();
                $("#areaAdmins-table tfoot").empty();
                $("#areaAdmins-table tbody").append("<tr><td colspan='6'>查询出错，请稍后再试！</td></tr>");
            }
        });
    }

    function build_areaAdmins_table(result) {
        $("#areaAdmins-table tbody").empty();
        var areaAdmins = result.extend.pageInfo.list;
        $.each(areaAdmins, function (index, areaAdmin) {
            var chkTd = $("<td></td>").addClass("tdCenter").append($("<input>").addClass("check_item").attr({"type": "checkbox"}));
            var areaAdminUserNameTd = $("<td></td>").append(areaAdmin.userName);
            var areaAdminUserAreaTd = $("<td></td>").append(areaAdmin.area.parentArea.parentArea.areaName + " " + areaAdmin.area.parentArea.areaName + " " + areaAdmin.area.areaName);
            var areaAdminUserOperatorTd = $("<td></td>").addClass("tdCenter").append(areaAdmin.userOperator.userName);
            var areaAdminUserOperatorTimeTd = $("<td></td>").addClass("tdCenter").append(areaAdmin.userOperatorTime);
            var editBtn = $("<button></button>").addClass("btn btn-sm btn-primary edit_btn").attr("data-toggle", "modal").attr("data-target", "#exampleModal")
                .append($("<span></span>").addClass("glyphicon glyphicon-edit")).append(" 修改");
            editBtn.attr({"edit-id": areaAdmin.id, "pn": result.extend.pageInfo.pageNum});
            var resPwdBtn = $("<button></button>").addClass("btn btn-sm btn-secondary passwordReset_btn")
                .append($("<span></span>").addClass("glyphicon glyphicon-lock")).append(" 重置密码");
            resPwdBtn.attr("reset-id", areaAdmin.id);
            var delBtn = $("<button></button>").addClass("btn btn-sm btn-danger delete_btn")
                .append($("<span></span>").addClass("glyphicon glyphicon-remove")).append(" 删除");
            delBtn.attr("delete-id", areaAdmin.id);
            var areaAdminOperationDiv = $("<div></div>").addClass("input-group").append($("<span></span>").addClass("input-group-btn").append(editBtn).append(resPwdBtn).append(delBtn));
            var areaAdminOperationTd = $("<td></td>").addClass("tdCenter").append(areaAdminOperationDiv);

            $("<tr></tr>").append(chkTd)
                .append(areaAdminUserNameTd)
                .append(areaAdminUserAreaTd)
                .append(areaAdminUserOperatorTd)
                .append(areaAdminUserOperatorTimeTd)
                .append(areaAdminOperationTd)
                .appendTo("#areaAdmins-table tbody");
        });
    }
    // <button type="button" class="btn btn-light page-link" data-toggle="modal"
    // data-target="#exampleModal">
    //     <span class="glyphicon glyphicon-plus"></span>
    // 新增
    // </button>
    // <button type="button" class="btn btn-light page-link" data-toggle="modal"
    // data-target="#exampleModal1">
    //     <span class="glyphicon glyphicon-remove"></span>
    // 删除
    // </button>

    function build_page_nav(result) {
        $("#areaAdmins-table tfoot").empty();

        var addBtn = $("<li></li>").append($("<a></a>").attr("id", "areaAdmin_add_btn").append($("<span></span>").addClass("glyphicon glyphicon-plus").append("新增")));
        var deleteBtnS =$("<li></li>").append($("<a></a>").attr("id", "areaAdmin_delete_all_btn").append($("<span></span>").addClass("glyphicon glyphicon-remove").append("批量删除")));
        var operatorUl = $("<ul></ul>").addClass("pagination pull-left")
        operatorUl.append(addBtn);
        operatorUl.append(deleteBtnS);

        var pageUl = $("<ul></ul>").addClass("pagination")
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        ;
        if (result.extend.pageInfo.isFirstPage) {
            firstPageLi.addClass("disabled");
        } else {
            firstPageLi.click(function () {
                to_page(2);
            });
        }
        pageUl.append(firstPageLi);

        var previousPageLi = $("<li></li>").append($("<a></a>").append("《"));
        if (result.extend.pageInfo.hasPreviousPage) {
            previousPageLi.click(function () {
                to_page(result.extend.pageInfo.pageNum - 1);
            });
        } else {
            previousPageLi.addClass("disabled");
        }
        pageUl.append(previousPageLi);
        $.each(result.extend.pageInfo.navigatepageNums, function (index, npNum) {
            var pageLi = $("<li></li>").append($("<a></a>").append(npNum));
            if (result.extend.pageInfo.pageNum == npNum) {
                pageLi.addClass("active");
            } else {
                pageLi.click(function () {
                    to_page(npNum);
                });
            }
            pageUl.append(pageLi);
        });
        var nextPageLi = $("<li></li>").append($("<a></a>").append("》"));
        if (result.extend.pageInfo.hasNextPage) {
            nextPageLi.click(function () {
                to_page(result.extend.pageInfo.pageNum + 1);
            });
        } else {
            nextPageLi.addClass("disabled");
        }
        pageUl.append(nextPageLi);
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        if (result.extend.pageInfo.isLastPage) {
            lastPageLi.addClass("disabled");
        } else {
            lastPageLi.click(function () {
                to_page(result.extend.pageInfo.pages);
            });
        }
        pageUl.append(lastPageLi);

        var pageInfoUl = $("<ul></ul>").addClass("pagination pull-right")
        var pageInfoLi = $("<li></li>").addClass("disabled").append($("<a></a>").append("当前第 " + result.extend.pageInfo.pageNum + " 页，总 "
            + result.extend.pageInfo.pages + " 页，总 "
            + result.extend.pageInfo.total + " 条记录"));
        pageInfoUl.append(pageInfoLi);

        pn = result.extend.pageInfo.pageNum;

        var pageNavTd = $("<td></td>").addClass("text-center")
            .attr({"colspan": 6}).append(operatorUl).append(pageUl).append(pageInfoUl);

        $("<tr></tr>").append(pageNavTd)
            .appendTo("#areaAdmins-table tfoot");
    }


    //单个删除
    $(document).on("click", ".delete_btn", function () {
        var userName = $(this).parents("tr").find("td:eq(1)").text();
        if (confirm("确认删除[ " + userName + " ]吗？")) {
            $.ajax({
                url: "../user/areaAdmin/" + $(this).attr("delete-id"),
                type: "delete",
                dataType: "json",
                success: function (result) {
                    alert(result.msg);
                    if (result.code = 100) {
                        //删除成功
                        //刷新用户列表显示
                        to_page(1);
                    }
                }
            });
        }
    });

    //全选全不选
    $("#check_all").click(function () {
        //attr用于获取自定义的属性值，prop用于获取或修改原生的
        // alert($(this).prop("checked"))
        $(".check_item").prop("checked", $(this).prop("checked"));
    })
    $(document).on("click", ".check_item", function () {
        var flg = $(".check_item").length == $(".check_item:checked").length;
        $("#check_all").prop("checked", flg);
    })

    //批量删除
    $(document).on("click", "#areaAdmin_delete_all_btn", function () {
        var userNames = "", ids = "";
        $.each($(".check_item:checked"), function () {
            userNames = userNames + $(this).parents("tr").find("td:eq(1)").text() + ",";
            ids = ids + $(this).parents("tr").find("td:eq(5)").find(".delete_btn").attr("delete-id") + "-";
        });
        userNames = userNames.substring(0, userNames.length - 1);
        ids = ids.substring(0, ids.length - 1);
        if (confirm("确认删除[ " + userNames + " ]吗？")) {
            $.ajax({
                url: "../user/areaAdmin/" + ids,
                type: "delete",
                dataType: "json",
                success: function (result) {
                    alert(result.msg);
                    if (result.code = 100) {
                        //删除成功
                        //刷新员工列表显示
                        to_page(1);
                        $("#check_all").prop("checked", false);
                    }
                }
            });
        }
    });


    //新增院校管理员模态框，并加载省份信息
    function getAreaList(element,txt,parentId,selText) {
        var url="list";
        if (parentId!=null){
            url = url+  "?parentId="+parentId;
        }
        // var url = "list";
        // if (parentId != null) {
        //     url = url + "?parentId=" + parentId;
        // }

        $.ajax({
            url:url,
            type:"GET",
            dataType:"json",
            success: function (result) {
                $(element).empty();
                if (txt != "") {
                    optionElement = $("<option></option>").append(txt).attr({"value": 0});
                    optionElement.appendTo($(element));
                }
                $.each(result.extend.areaList, function (index, area) {
                    optionElement = $("<option></option>").append(area.areaName).attr({"value": area.id});
                    optionElement.appendTo($(element));
                });
                $(element).removeAttr("disabled");
                $(element).selectpicker("refresh");
                if (selText != "") {
                    $(element).next().prop("title", selText);
                    $(element).next().find("div.filter-option-inner-inner").html(selText);
                    $(element).next().removeClass("bs-placeholder");
                }
            }
        })
    }

    $(document).on("click", "#areaAdmin_add_btn", function () {
        getAreaList("#provinceSelect_add_modal", "", "", "");
        $("#areaAdmin_add_modal").modal({
            "backdrop": "static"
        });
    });


    //省、市、院校联动
    $("#provinceSelect_add_modal").on("changed.bs.select", function () {

        $("#citySelect_add_modal").empty();
        $("#citySelect_add_modal").attr("disabled", "disabled");
        $("#citySelect_add_modal").selectpicker("refresh");
        $("#schoolSelect_add_modal").empty();
        $("#schoolSelect_add_modal").attr("disabled", "disabled");
        $("#schoolSelect_add_modal").selectpicker("refresh");

        getAreaList("#citySelect_add_modal", "", $(this).val(), "");
    });

    $("#citySelect_add_modal").on("changed.bs.select", function () {

        $("#schoolSelect_add_modal").empty();
        $("#schoolSelect_add_modal").attr("disabled", "disabled");
        $("#schoolSelect_add_modal").selectpicker("refresh");
        if ($(this).val() > 0) {
            getAreaList("#schoolSelect_add_modal", "", $(this).val(), "");
        }
    });

    //模态框隐藏，重置窗体
    $(document).on('hidden.bs.modal', '.modal', function () {
        $("#areaAdmin_add_modal form")[0].reset();
        $("#areaAdmin_add_modal form").find("*").removeClass("has-error has-success");
        $("#areaAdmin_add_modal form").find(".help-block").text("");



        $(".modal .selectpicker").empty();
        $(".modal .selectpicker").attr("disabled", "disabled");
        $(".modal .selectpicker").selectpicker("refresh");
    });


    //新增院校管理员模态框保存操作
    $("#areaAdmin_save_btn").click(function () {
        //数据校验

        //新增院校管理员的异步请求
        $.ajax({
            url: "../user/areaAdmin",
            data: $("#areaAdmin_add_frm").serialize(),
            type: "post",
            dataType: "json",
            success: function (result) {
                if (result.code == 100) {
                    //添加成功，刷新所有地域信息
                    $("#areaAdmin_add_modal").modal('hide');
                    alert("院校管理员信息添加成功！");
                    to_page(1);
                    $("#check_all").prop("checked", false);
                    //自主完成
                }
            }
        });
    });

    //修改
    $(document).on("click", ".edit_btn", function () {
        $.ajax({
            url: "../user/areaAdmin",
            data: {"id": $(this).attr("edit-id")},
            type: "GET",
            dataType: "json",
            success: function (result) {
                if (result.code == 100) {
                    $("#userName_modify_modal").val(result.extend.areaAdmin.userName);
                    getAreaList("#provinceSelect_modify_modal", "", "", result.extend.areaAdmin.area.parentArea.parentArea.areaName);
                    getAreaList("#citySelect_modify_modal", "", result.extend.areaAdmin.area.parentArea.parentArea.id,
                        result.extend.areaAdmin.area.parentArea.areaName);
                    getAreaList("#schoolSelect_modify_modal", "", result.extend.areaAdmin.area.parentArea.id, result.extend.areaAdmin.area.areaName);

                }
            }
        });

        $("#areaAdmin_modify_btn").attr("edit-id", $(this).attr("edit-id"));
        $("#areaAdmin_modify_modal").modal({
            "backdrop": "static"
        });
    });


    $("#provinceSelect_modify_modal").on("changed.bs.select", function () {

        $("#citySelect_modify_modal").empty();
        $("#citySelect_modify_modal").attr("disabled", "disabled");
        $("#citySelect_modify_modal").selectpicker("refresh");
        $("#schoolSelect_modify_modal").empty();
        $("#schoolSelect_modify_modal").attr("disabled", "disabled");
        $("#schoolSelect_modify_modal").selectpicker("refresh");

        getAreaList("#citySelect_modify_modal", "", $(this).val(), "");
    });

    $("#citySelect_modify_modal").on("changed.bs.select", function () {

        $("#schoolSelect_modify_modal").empty();
        $("#schoolSelect_modify_modal").attr("disabled", "disabled");
        $("#schoolSelect_modify_modal").selectpicker("refresh");
        if ($(this).val() > 0) {
            getAreaList("#schoolSelect_modify_modal", "", $(this).val(), "");
        }
    });

    $("#areaAdmin_modify_btn").click(function () {
        //数据校验
        //新增院校管理员的异步请求
        $.ajax({
            url: "../user/areaAdmin/" + $(this).attr("edit-id"),
            data: $("#areaAdmin_modify_frm").serialize(),
            type: "put",
            dataType: "json",
            success: function (result) {
                if (result.code == 100) {
                    //修改成功，刷新所有地域信息
                    $("#areaAdmin_modify_modal").modal('hide');
                    alert("院校管理员信息修改成功！");
                    to_page(1);
                    $("#check_all").prop("checked", false);
                    //自主完成
                }
            }
        });
    });

    $(document).on("click", ".passwordReset_btn", function () {
        $.ajax({
            url: "../user/passwordReset",
            data: {"id": $(this).attr("reset-id")},
            type: "post",
            dataType: "json",
            success: function (result) {
                if (result.code == 100) {
                    alert("密码重置成功！");
                }
            }
        });
    });


    $("#provinceSelect").on("changed.bs.select", function () {

        $("#citySelect").empty();
        $("#citySelect").attr("disabled", "disabled");
        $("#citySelect").selectpicker("refresh");
        $("#schoolSelect").empty();
        $("#schoolSelect").attr("disabled", "disabled");
        $("#schoolSelect").selectpicker("refresh");
        if ($(this).val() > 0) {
            getAreaList("#citySelect", "全部城市", $(this).val(), "");
        }
    });

    $("#citySelect").on("changed.bs.select", function () {

        $("#schoolSelect").empty();
        $("#schoolSelect").attr("disabled", "disabled");
        $("#schoolSelect").selectpicker("refresh");
        if ($(this).val() > 0) {
            getAreaList("#schoolSelect", "全部院校", $(this).val(), "");
        }
    });

    $("#reset_btn").click(function () {
        getAreaList("#provinceSelect", "全部省份", "", "");
        $("#citySelect").empty();
        $("#citySelect").attr("disabled", "disabled");
        $("#citySelect").selectpicker("refresh");
        $("#schoolSelect").empty();
        $("#schoolSelect").attr("disabled", "disabled");
        $("#schoolSelect").selectpicker("refresh");
        $("#userName_search_input").val("");
    });

    $("#search_btn").click(function () {
        if ($("#provinceSelect").val() == "") {
            provinceId = 0;
        } else {
            provinceId = $("#provinceSelect").val();
        }
        if ($("#citySelect").val() == "") {
            cityId = 0;
        } else {
            cityId = $("#citySelect").val();
        }
        if ($("#schoolSelect").val() == "") {
            schoolId = 0;
        } else {
            schoolId = $("#schoolSelect").val();
        }
        userName = $("#userName_search_input").val();
        to_page(pn);
    });








</script>
</body>
</html>
